#include <WinSock2.h>
#include <stdio.h>

int main()
{
	WORD wVersionRequested;
	WSADATA wsaDAta;
	int err;

	wVersionRequested = MAKEWORD(1, 1);

	err = WSAStartup(wVersionRequested, &wsaDAta);
	if(err != 0)
		return 1;

	if(LOBYTE(wsaDAta.wVersion) != 1 || HIBYTE(wsaDAta.wVersion) != 1)
	{
		WSACleanup();
		return 1;
	}

	SOCKET sockSrv = socket(AF_INET, SOCK_STREAM, 0);

	SOCKADDR_IN addrSvr;
	addrSvr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
	addrSvr.sin_family = AF_INET;
	addrSvr.sin_port = htons(6000);

	bind(sockSrv, (SOCKADDR*)&addrSvr, sizeof(SOCKADDR));

	listen(sockSrv, 5);

	SOCKADDR_IN addrClient;
	int len = sizeof(SOCKADDR);

	while(1)
	{
		SOCKET sockConn = accept(sockSrv, (SOCKADDR*)&addrClient, &len);
		char sendBuf[100];
		sprintf(sendBuf, "Welcome %s to http:\\www.fuckyou.org",
			inet_ntoa(addrClient.sin_addr));

		send(sockConn, sendBuf, strlen(sendBuf)+1,0);
		char recvBuf[100];

		recv(sockConn, recvBuf, 100, 0);

		printf("%s\n",recvBuf);

		closesocket(sockConn);
	}
	return 0;
}
